package com.lineage.config;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
import java.util.StringTokenizer;
import org.apache.commons.logging.Log;

public final class ConfigGuaji {
  public static boolean Guaji_tele;
  
  public static int Guaji_tele_item;
  
  public static int Guaji_tele_itemcount;
  
  public static int itemadena1;
  
  public static int itemadena2;
  
  public static int itemadena3;
  
  public static int itemadena4;
  
  public static int itemadena5;
  
  public static int itemadena6;
  
  public static int itemadena7;
  
  public static int itemadena8;
  
  public static int itemadena9;
  
  public static int itemadena21;
  
  public static int itemadena22;
  
  public static boolean followtele;
  
  public static boolean Guaji_save;
  
  public static int Guaji_level;
  
  public static String guaji;
  
  public static double adena;
  
  public static double guajiexp2;
  
  public static boolean checktimeguaji;
  
  public static boolean Guaji_action;
  
  public static int[] Guaji_map_stopskill;
  
  public static int[] GUAJI_ITEM;
  
  public static double guaji_hu_exp;
  
  public static double guaji_hu_adena;
  
  public static int guaji_check;
  
  private static Log _log;
  
  private static final String OTHER_SETTINGS_FILE = "./config/其他控制端/挂机相关设置表.properties";
  
  public static void load() throws ConfigErrorException {
    Properties set = new Properties();
    try {
      InputStream is = new FileInputStream(new File("./config/其他控制端/挂机相关设置表.properties"));
      InputStreamReader isr = new InputStreamReader(is, "utf-8");
      set.load(isr);
      is.close();
      guaji_hu_exp = Double.parseDouble(set.getProperty("guaji_hu_exp", "0.0"));
      guaji_hu_adena = Double.parseDouble(set.getProperty("guaji_hu_adena", "0.0"));
      guaji_check = Integer.parseInt(set.getProperty("guaji_check", "100"));
      Guaji_tele = Boolean.parseBoolean(set.getProperty("Guaji_tele", "true"));
      Guaji_tele_item = Integer.parseInt(set.getProperty("Guaji_tele_item", "100"));
      Guaji_tele_itemcount = Integer.parseInt(set.getProperty("Guaji_tele_itemcount", "100"));
      guaji = set.getProperty("guaji", "");
      adena = Double.parseDouble(set.getProperty("adena", "0.0"));
      if (adena < 0.0D)
        adena = 0.0D; 
      itemadena1 = Integer.parseInt(set.getProperty("itemadena1", "100"));
      itemadena2 = Integer.parseInt(set.getProperty("itemadena2", "100"));
      itemadena3 = Integer.parseInt(set.getProperty("itemadena3", "100"));
      itemadena4 = Integer.parseInt(set.getProperty("itemadena4", "100"));
      itemadena5 = Integer.parseInt(set.getProperty("itemadena5", "100"));
      itemadena6 = Integer.parseInt(set.getProperty("itemadena6", "100"));
      itemadena7 = Integer.parseInt(set.getProperty("itemadena7", "100"));
      itemadena8 = Integer.parseInt(set.getProperty("itemadena8", "100"));
      itemadena9 = Integer.parseInt(set.getProperty("itemadena9", "100"));
      itemadena21 = Integer.parseInt(set.getProperty("itemadena21", "100"));
      itemadena22 = Integer.parseInt(set.getProperty("itemadena22", "100"));
      Guaji_save = Boolean.parseBoolean(set.getProperty("Guaji_save", "true"));
      Guaji_level = Integer.parseInt(set.getProperty("Guaji_level", "100"));
      GUAJI_ITEM = toIntArray(set.getProperty("GUAJI_ITEM", ""), ",");
      Guaji_map_stopskill = toIntArray(set.getProperty("Guaji_map_stopskill", ""), ",");
      checktimeguaji = Boolean.parseBoolean(set.getProperty("checktimeguaji", "true"));
      followtele = Boolean.parseBoolean(set.getProperty("followtele", "true"));
      guajiexp2 = Double.parseDouble(set.getProperty("guajiexp2", "0.0"));
      Guaji_action = Boolean.parseBoolean(set.getProperty("Guaji_action", "true"));
    } catch (Exception e) {
      throw new ConfigErrorException("设置档案遗失: ./config/其他控制端/挂机相关设置表.properties");
    } finally {
      set.clear();
    } 
  }
  
  public static int[] toIntArray(String text, String type) {
    StringTokenizer st = new StringTokenizer(text, type);
    int[] iReturn = new int[st.countTokens()];
    int i = 0;
    while (i < iReturn.length) {
      iReturn[i] = Integer.parseInt(st.nextToken());
      i++;
    } 
    return iReturn;
  }
}
